'''
Python by Marshall
-*- coding: utf-8 -*-
'''

import django_filters

from UShop.models import Sku, TbGoods


class SkuFilter(django_filters.rest_framework.FilterSet):
    """商品过滤器"""
    sku_min =django_filters.NumberFilter(field_name='sku_price',lookup_expr='gte')
    sku_max = django_filters.NumberFilter(field_name='sku_price', lookup_expr='lte')
    #模糊查询，其中'contains'代表区分大小写，'icontains'代表不区分大小写
    name = django_filters.CharFilter(field_name='sku_name', lookup_expr='icontains')
    class Meta:
        model = Sku
        fields = ['sku_min','sku_max','name']


class SpuFilter(django_filters.rest_framework.FilterSet):
    """商品过滤器"""
    spu_min =django_filters.NumberFilter(field_name='spu_id',lookup_expr='gte')
    spu_max = django_filters.NumberFilter(field_name='spu_id', lookup_expr='lte')
    #模糊查询，其中'contains'代表区分大小写，'icontains'代表不区分大小写
    name = django_filters.CharFilter(field_name='sup_name', lookup_expr='icontains')
    class Meta:
        model = TbGoods
        fields = ['spu_min','spu_max','name']